﻿using DatabaseCore.Modal;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace DatabaseCore
{
    public interface DataSourceClient
    {

        /// <summary>
        /// 插入单个实体，返回实体
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <returns></returns>
        T Install<T>(T t) where T : class, new();

        /// <summary>
        /// 更新实体
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <returns></returns>
        int Update<T>(T t) where T : class, new();

        int Update<T>(List<T> t) where T : class, new();

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        List<T> QueryAll<T>() where T : class, new();

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="whereExpression"></param>
        /// <returns></returns>
        List<T> Query<T>(System.Linq.Expressions.Expression<Func<T, bool>> whereExpression) where T : class, new();

        T QueryOne<T>(Expression<Func<T, bool>> whereExpression) where T : class, new();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pt"></param>
        /// <param name="stationName"></param>
        /// <param name="materialName"></param>
        /// <returns></returns>
        string Query(string pt, string stationName, string materialName);

        bool Delete<T>(T t, Expression<Func<T, bool>> WhereCondition = null) where T : class, new();
        bool Delete<T>(Expression<Func<T, bool>> WhereCondition = null) where T : class, new();

        List<SystemTable> FindDatabaseTableNames();

        List<TableStructure> FindTableStructures(string tableName);

        DBResult QueryBySql(string Sql);

        int ExecuteSql(string Sql);

        DBResult PageQueryBySql(string Sql, string TableName, int Page, int Size);
    }
}
